<script type="text/javascript">
	//2.2 ES6 解构赋值
	//数组模型的解构（Array）

	//基本
	let [a, b, c] = [1, 2, 3];
	document.write(a+'  '+b+'  '+c);

	//可嵌套
	let [a1, [[b1], c1]] = [1, [[2], 3]];
	document.write('<br>');
	document.write(a1+'  '+b1+'  '+c1);

	//可忽略
	let [a2, , b2] = [1, 2, 3];
	document.write('<br>');
	document.write(a2+'  '+b2);

	//不完全解构
	let [a3 = 1, b3] = []; 
	document.write('<br>');
	document.write(a3+'  '+b3);

	//剩余运算符
	let [a4, ...b4] = [1, 2, 3];
	document.write('<br>');
	document.write(a4+'  '+b4);


	//对象模型的解构（Object）
	//基本
	let { foo, bar } = { foo: 'aaa', bar: 'bbb' };
	document.write('<br>');
	document.write(foo+'  '+bar);


	let { baz1 : foo1 } = { baz1 : 'ddd' };
	document.write('<br>');
	document.write(foo1);

	//可嵌套可忽略
	let obj = {p: ['hello', {y: 'world'}] };
	let {p: [x, { y }] } = obj;
	document.write('<br>');
	document.write(x+'  '+y);

	let obj1 = {p: ['hello', {y1: 'world'}] };
	let {p: [x1, {  }] } = obj1;
	document.write('<br>');
	document.write(x1);

	//不完全解构
	let obj2 = {p: [{y2: 'world'}] };
	let {p: [{ y2 }, x2 ] } = obj2;
	document.write('<br>');
	document.write(x2+'  '+y2);

	//剩余运算符
	let {a5, b5, ...rest} = {a5: 10, b5: 20, c: 30, d: 40};
	document.write('<br>');
	document.write(a5+'  '+b5+'  '+rest);

	//解构默认值
	let {a6 = 10, b6 = 5} = {a6: 3};
	document.write('<br>');
	document.write(a6+'  '+b6);

	let {a7: aa = 10, b7: bb = 5} = {a7: 3};
	document.write('<br>');
	document.write(aa+'  '+bb);
</script>